<template>
<div class="newsLists clearfix">
  <ul v-for="item of com">
    <li>{{item.title}}</li>
    <span>{{item.time}}</span>
  </ul>
</div>
</template>

<script>
export default {
  data () {
    return {
      real: [],
      com: 0
    }
  },
  methods : {
    scrollMethod () {
      const sumH = document.body.scrollHeight
      const viewH = document.documentElement.clientHeight
      const scrollH = document.body.scrollTop
      if (viewH + scrollH >= (sumH - 100)) {
        this.getData()
      }
    },
    getData () {
      this.limit += 10,
      this.$http({
        url: 'http://localhost:2000/getjson/comNews',
        method: 'get',
        params: {
          page: 1,
          limit: this.limit,
          mdrender: 'false'
        }
      }).then((res) => {
        this.com = res.data.lists
      }).catch((res) => {
        console.log('error:',res)
      })
    }
  },
  mounted() {
    this.getData();
    window.addEventListener('scroll', this.scrollMethod)
  }
}
</script>

<style scoped>

</style>

